package Messages;

import java.io.IOException;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

import Server.SQLConnection;
import ocsf.server.ConnectionToClient;


public class MessageUnknowStep {

	private ConnectionToClient client ;
	private ArrayList<Object> str ;
	private ResultSet RunNewRs;
public MessageUnknowStep(ArrayList<Object> msg, ConnectionToClient client) {
		
		this.client= client ;
		this.str= msg; 		
		
	}

public void Load(String StepId,String ScenarioName, String Actual, String Comment) throws SQLException, IOException {
	SQLConnection sc = new SQLConnection();
	
	java.sql.PreparedStatement ScenarioTemp = sc.getConnection().prepareStatement("UPDATE hts."+ScenarioName+" SET Actual= ?, Comment =?, Status= ?  where idScenario='"+StepId+"';");
	ScenarioTemp.setString(1, Actual);
	ScenarioTemp.setString(2, Comment);
	ScenarioTemp.setString(3, "Unknow");
	ScenarioTemp.executeUpdate();
	
	ScenarioTemp.close();
	
	java.sql.PreparedStatement ScenarioTempPass = sc.getConnection().prepareStatement("SELECT t.`idScenario`,t.`TestDescription`,t.`Status` FROM hts."+ScenarioName+" t;");


	RunNewRs= ScenarioTempPass.executeQuery();
	
	ArrayList<Object> Run =new ArrayList<Object>();
	Run.add("RunStepFirst");
	Run.add(ScenarioName);
	Run.add(StepId);
	while (RunNewRs.next())
	{
		Run.add(RunNewRs.getInt(1));
		Run.add(RunNewRs.getString(2));
		//Run.add(RunNewRs.getString(3));
		//Run.add(RunNewRs.getString(4));
		//Run.add(RunNewRs.getString(5));
		Run.add(RunNewRs.getString(3));
		//Run.add(RunNewRs.getString(7));

	}
	
	ScenarioTemp.close();
	
	client.sendToClient(Run);
	
	
	
	
}

}
